package com.example.second_home_work

import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {

    val expert = ProgramExpert()

    var count =0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        val button2=findViewById<Button>(R.id.button2)
        val spinner=findViewById<Spinner>(R.id.spinner)
        button2.setOnClickListener {
            val textView=findViewById<TextView>(R.id.textView)
            textView.text = expert.getLanguage(spinner.selectedItem.toString())

        }
        
        val button = findViewById<Button>(R.id.button)
        val linearLayout = findViewById<LinearLayout>(R.id.LinearLayout)

        button.setOnClickListener {
            val textView = TextView(this)
            count++
            textView.text ="new textview $count"
            linearLayout.addView(textView)
        }
    }
}